Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@types/d3-format
Advanced tools
TypeScript definitions for d3-format
The @types/d3-format package provides TypeScript type definitions for the d3-format module, which is a JavaScript library for formatting numbers for human consumption. It allows developers to format numbers in various ways, such as currency, percentage, precision, and more. The type definitions enable TypeScript developers to use d3-format with type checking and IntelliSense in their IDEs.
Number Formatting
Format numbers to a fixed number of decimal places.
import { format } from 'd3-format';
const formatter = format('.2f');
const formattedNumber = formatter(123.456); // '123.46'
Currency Formatting
Format numbers as currency, including symbol, comma separation, and decimal precision.
import { format } from 'd3-format';
const currencyFormatter = format('$,.2f');
const formattedCurrency = currencyFormatter(1234.56); // '$1,234.56'
Percentage Formatting
Format numbers as percentages with rounding and no decimal places.
import { format } from 'd3-format';
const percentFormatter = format('.0%');
const formattedPercent = percentFormatter(0.123); // '12%'
SI Prefix Formatting
Format numbers using SI prefixes with a specified precision.
import { format } from 'd3-format';
const siFormatter = format('.3s');
const formattedSI = siFormatter(123456); // '123k'
Numeral is a standalone library for formatting and manipulating numbers. It offers a wide range of formatting options and is similar to d3-format in its purpose. However, it does not require D3 and has its own syntax for specifying formats.
Accounting.js is a tiny JavaScript library for number, money and currency formatting, which also offers some basic arithmetic and utility functions. It is similar to d3-format in terms of currency formatting but is more focused on accounting and financial operations.
Globalize provides number formatting and parsing, currency formatting, and date and time formatting that are culture-aware. It is based on the Unicode Consortium's Common Locale Data Repository (CLDR). It is more comprehensive than d3-format in terms of internationalization support.
npm install --save @types/d3-format
This package contains type definitions for d3-format (https://github.com/d3/d3-format/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/d3-format.
These definitions were written by Tom Wanzek, Alex Ford, Boris Yankov, denisname, and Nathan Bierema.
FAQs
TypeScript definitions for d3-format
We found that @types/d3-format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.